import { createApp } from "vue";
import ElementPlus from "element-plus";
import "element-plus/dist/index.css";
import * as ElementPlusIconsVue from "@element-plus/icons-vue";
import * as echarts from "echarts";
import App from "./App.vue";
// import { createPinia } from 'pinia'
import pinia from "./store/store";
import axios from 'axios'
import router from "./router";
import layoutList from "@/layout/index.vue";
import "@/assets/index.scss";
import common from "./utils/common";
import utilsIndex from "./utils/index"
import config from "./utils/config"
// 列表组件
import ListPage from "./layout/components/listPage.vue";
// const pinia = createPinia()
const app = createApp(App);
// 公共方法
app.config.globalProperties.$common = common;
app.config.globalProperties.$utilsIndex = utilsIndex;
app.config.globalProperties.$config = config;


// 公共组件
app.component("layoutList", layoutList);
app.component("List_Page", ListPage);
// 进入路由的地址 判断是否有token，没token去登录页面
router.beforeEach((to, from, next) => {
  if (to.path === "/Login") {
    next();
  } else {
    if (sessionStorage.getItem("TOKEN")) {
      next();
    } else {
      next({ path: "/Login" });
    }
  }
});

for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component);
}

console.log(process.env.NODE_ENV);
console.log(process);
 

// axios({
//   method:"POST",
//   url:"http://192.168.2.112:8089/login/add",
//   data:{userName:"小红",userPass:'123456',phone:"15214006828",position:"前端工程师"}
// }).then(res => {
//   console.log(res.data);
// })
app.use(router);
app.use(pinia);
app.use(ElementPlus);
app.mount("#app");
